package org.feng.controller;

import lombok.extern.slf4j.Slf4j;
import org.feng.common.dto.HelloRequest;
import org.feng.common.dto.HelloResponse;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * openfeign 控制器
 *
 * @author feng
 */
@Slf4j
@RequestMapping("/hello")
@RestController
public class HelloOpenFeignController {

    @PostMapping("/post")
    public HelloResponse postHello(@RequestBody HelloRequest helloRequest) {
        log.info("request：{}", helloRequest);

        HelloResponse response = new HelloResponse();
        response.setTitle(helloRequest.getTitle());
        response.setLocalDateTime(helloRequest.getLocalDateTime());
        response.setFromHost(helloRequest.getHost());
        response.setFromPort(helloRequest.getPort());

        log.info("response: {}", response);
        return response;
    }
}
